package com.zhou.blog.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @title:DateUtils
 * @Author Zhou
 * @Date:2022/5/8 22:44
 * @Version 1.0
 */
public class DateUtils {
    public static Map<String,Long> date(String year,String month){
        StringBuilder endMonth = new StringBuilder();
        StringBuilder endYear = new StringBuilder();
        Map<String,Long> dateMap = new HashMap<>();
        if (month.equals("12")) {
            endMonth.append("01");
            endYear.append(Integer.parseInt(year) + 1);

        }else {
            endYear.append(year);
            endMonth.append(Integer.parseInt(month) + 1);
        }
        String startDate = year + "-" + month + "-01";
        String endDate = endYear + "-" + endMonth + "-01";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date startDates = null;
        Date endDates = null;
        try {
            startDates = simpleDateFormat.parse(startDate);
            endDates = simpleDateFormat.parse(endDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        long startDatesTime = startDates.getTime();
        long endDatesTime = endDates.getTime();
        dateMap.put("startDatesTime",startDatesTime);
        dateMap.put("endDatesTime",endDatesTime);
        return dateMap;
    }
}
